package cn.bandeqing.order.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.base.resp.Table;
import cn.bandeqing.finance.resp.LabelValue;
import cn.bandeqing.order.req.*;
import cn.bandeqing.order.resp.*;
import cn.bandeqing.order.rpc.IOrderRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/order")
@RestController
@Tag(name = "订单")
public class OrderController {

    @DubboReference
    private IOrderRpc orderRpc;

    @Operation(summary = "cancelDouyin")
    @PostMapping("/cancelDouyin")
    public Resp<Void> cancelDouyin(@RequestBody @Valid CancelDouyinReq req) {
        return orderRpc.cancelDouyin(req);
    }

    @Operation(summary = "orderDouyinVerify")
    @PostMapping("/orderDouyinVerify")
    public Resp<Void> orderDouyinVerify(@RequestBody @Valid OrderDouyinVerifyReq req) {
        return orderRpc.orderDouyinVerify(req);
    }

    @Operation(summary = "douyinVerify")
    @PostMapping("/douyinVerify")
    public Resp<Void> douyinVerify(@RequestBody @Valid DouyinVerifyReq req) {
        return orderRpc.douyinVerify(req);
    }

    @Operation(summary = "productSpecificationsSelect")
    @PostMapping("/productSpecificationsSelect")
    public Resp<List<LabelValue>> productSpecificationsSelect(@RequestBody @Valid OrderProductSpecificationsSelectReq req) {
        return orderRpc.productSpecificationsSelect(req);
    }

    @Operation(summary = "productSelect")
    @PostMapping("/productSelect")
    public Resp<List<LabelValue>> productSelect(@RequestBody @Valid OrderProductSelectReq req) {
        return orderRpc.productSelect(req);
    }

    @Operation(summary = "productRemove")
    @PostMapping("/productRemove")
    public Resp<OrderPriceDetails> productRemove(@RequestBody @Valid OrderProductRemoveReq req) {
        return orderRpc.productRemove(req);
    }

    @Operation(summary = "productSave")
    @PostMapping("/productSave")
    public Resp<OrderPriceDetails> productSave(@RequestBody @Valid OrderProductSaveReq req) {
        return orderRpc.productSave(req);
    }

    @Operation(summary = "productTable")
    @PostMapping("/productTable")
    public Resp<Table<OrderProductTable>> productTable(@RequestBody @Valid OrderProductTableReq req) {
        return orderRpc.productTable(req);
    }

    @Operation(summary = "discountsSave")
    @PostMapping("/discountsSave")
    public Resp<OrderPriceDetails> discountsSave(@RequestBody @Valid OrderDiscountsSaveReq req) {
        return orderRpc.discountsSave(req);
    }

    @Operation(summary = "discountsTable")
    @PostMapping("/discountsTable")
    public Resp<Table<OrderDiscountsTable>> discountsTable(@RequestBody @Valid OrderDiscountsTableReq req) {
        return orderRpc.discountsTable(req);
    }

    @Operation(summary = "modifyStatus")
    @PostMapping("/modifyStatus")
    public Resp<Void> modifyStatus(@RequestBody @Valid OrderModifyStatusReq req) {
        return orderRpc.modifyStatus(req);
    }

    @Operation(summary = "detail")
    @PostMapping("/detail")
    public Resp<OrderDetailResp> detail(@RequestBody @Valid OrderDetailReq req) {
        return orderRpc.detail(req);
    }

//    @Operation(summary = "create")
//    @PostMapping("/create")
//    public Resp<Void> create(@RequestBody @Valid OrderCreateReq req) {
//        orderRpc.create(req);
//        return Resp.success();
//    }

    @Operation(summary = "表格")
    @PostMapping("/table")
    public Resp<Table<OrderTable>> table(@RequestBody @Valid OrderTableReq req) {
        return orderRpc.table(req);
    }

    @Operation(summary = "创建或更新")
    @PostMapping("/saveOrUpdate")
    public Resp<Void> saveOrUpdate(@RequestBody @Valid OrderSaveOrUpdateReq req) {
        orderRpc.saveOrUpdate(req);
        return Resp.success();
    }

}
